************************************
* Replication file for:            *
*                                  *
* "From Economic Competition       *
* to Military Combat: Export       *
* Similarity and International     *
* Conflict" (appendix)             *
*                                  *
* J. Tyson Chatagnier and Kerim    *
* Can Kavakli                      *
*                                  *
* Published in the Journal of      *
* Conflict Resolution              *
************************************

/* Load data */
use "export_similarity_data.dta", clear


**********************
* Appendix - Table 2 *
**********************

* main variables
local propsim_main    "l.exports_2digit l.lowerdep2015"  
local model       "appx2"

* controls
local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.s3un majmaj majmin l.rivalry both_europe dec_1 dec_2 dec_3"
local extra_controls  ""

* 1st dependent variable - All MIDs
local dv    "mid_init mid_py*"
local dv_abbr "a_"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

local extra_controls  "l.low_gdppc l.joint_gatt l.lower_open"
  
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'_extra


* 2nd dependent variable - Fatal MIDs
local dv    "fatal_init fatal_py*"
local dv_abbr "f_"

local extra_controls  ""

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

local extra_controls  "l.low_gdppc l.joint_gatt l.lower_open"
  
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'_extra
  

* 3rd dependent variable - High-Hostility MIDs
local dv    "hihost_init hihost_py*"
local dv_abbr "h_"

local extra_controls  ""

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

local extra_controls  "l.low_gdppc l.joint_gatt l.lower_open"
  
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'_extra  

  
* Appendix - Table 2
esttab a_appx2* f_appx2* h_appx2*, b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*py* *dec*) order(L.exports* *lowerdep*)                          


**********************
* Appendix - Table 3 *
**********************

* controls
local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.s3un majmaj majmin l.rivalry both_europe dec_1 dec_2 dec_3"
local extra_controls  ""

* dependent variable - All MIDs
local dv    "mid_init mid_py*"
local dv_abbr "a_"

* 1st main variable - zeroes removed if commodity is not exported by at least one state in dyad
local propsim_main    "l.exports_nozero l.lowerdep2015"  
local model       "appx3a"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

*
* 2nd main variable - zeroes removed if neither state exports the commodity
local propsim_main    "l.exports_nozeroeither l.lowerdep2015"  
local model       "appx3b"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

  
* Appendix - Table 3
esttab a_appx3*, b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*py* *dec*) order(L.exports* *lowerdep*)                          


**********************
* Appendix - Table 4 *
**********************

preserve

* Only "politically relevant" dyads
keep if polrel ==1

* main variables
local propsim_main    "l.exports l.lowerdep2015"  
local model       "appx4"

* controls
local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.s3un majmaj majmin l.rivalry both_europe dec_1 dec_2 dec_3"
local extra_controls  ""

* 1st dependent variable - All MIDs
local dv    "mid_init mid_py*"
local dv_abbr "a_"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

local extra_controls  "l.low_gdppc l.joint_gatt l.lower_open"
  
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'_extra

* 2nd dependent variable - Fatal MIDs
local dv    "fatal_init fatal_py*"
local dv_abbr "f_"

local extra_controls  ""

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

local extra_controls  "l.low_gdppc l.joint_gatt l.lower_open"
  
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'_extra
  

* 3rd dependent variable - High-Hostility MIDs
local dv    "hihost_init hihost_py*"
local dv_abbr "h_"

local extra_controls  ""

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

local extra_controls  "l.low_gdppc l.joint_gatt l.lower_open"
  
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'_extra  

restore
  
* Appendix - Table 4
esttab a_appx4* f_appx4* h_appx4*, b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*py* *dec*) order(L.exports *lowerdep*)                           


**********************
* Appendix - Table 5 *
**********************

preserve

* dependent variable - All MIDs
local dv    "mid_init mid_py*"
local dv_abbr "a_"

* main variables
local propsim_main    "l.exports l.lowerdep2015"  
local model       "appx5_m1"

* controls
local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.s3un majmaj majmin l.rivalry both_europe dec_1 dec_2 dec_3"
local extra_controls  ""

* Model 1 in Appendix Table 5: No extreme values of export similarity
*keep if l.exports > -0.009 & l.exports <0.53 & l.exports !=.
keep if l.exports > -0.00967 & l.exports <0.535 & l.exports !=.

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

restore


preserve
* Model 2 in Appendix Table 5: Only major powers

keep if majmaj ==0 & majmin ==0
local model   "appx5_m2"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

restore


preserve
* Model 3 in Appendix Table 5: Minimalist specification

local controls  "contig_dummy l.pwin_cap"
local model   "appx5_m3"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

restore


preserve
* Model 4 in Appendix Table 5: Bretton Wood indicator

gen brettonwoods =0
replace brettonwoods =1 if year <1973

local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.s3un majmaj majmin l.rivalry both_europe dec_1 dec_2 dec_3"
local extra_controls  "brettonwoods"
local model       "appx5_m4"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'
  
restore 


preserve
* Model 5 in Appendix Table 5: Alliance dummy instead of UN voting measure

local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.allied majmaj majmin l.rivalry both_europe dec_1 dec_2 dec_3"
local extra_controls  ""
local model       "appx5_m5"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'
  
restore 


* Appendix - Table 5
esttab a_appx5*, b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*py* *dec*) order(L.exports *lowerdep*)                           


**********************
* Appendix - Table 6 *
**********************

* main variables
local propsim_main    "l.exports l.lower_depgdp"  
local model       "appx6"

* controls
local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.s3un majmaj majmin l.rivalry both_europe dec_1 dec_2 dec_3"
local extra_controls  ""

* 1st dependent variable - All MIDs
local dv    "mid_init mid_py*"
local dv_abbr "a_"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

local extra_controls  "l.low_gdppc l.joint_gatt l.lower_open"
  
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'_extra


* 2nd dependent variable - Fatal MIDs
local dv    "fatal_init fatal_py*"
local dv_abbr "f_"

local extra_controls  ""

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

local extra_controls  "l.low_gdppc l.joint_gatt l.lower_open"
  
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'_extra
  

* 3rd dependent variable - High-Hostility MIDs
local dv    "hihost_init hihost_py*"
local dv_abbr "h_"

local extra_controls  ""

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

local extra_controls  "l.low_gdppc l.joint_gatt l.lower_open"
  
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'_extra  

  
* TABLE 6
esttab a_appx6* f_appx6* h_appx6*, b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*py* *dec*) order(L.exports *lowerdep*)                           


**********************
* Appendix - Table 7 *
**********************
    
* main variables
local propsim_main    "l.exports l.lowerdep2015"  
local model       "appx7"

* controls
local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.s3un majmaj majmin l.rivalry both_europe dec_1 dec_2 dec_3"

* dependent variable - All MIDs
local dv    "mid_init mid_py*"
local dv_abbr "a_"

* control for Lupu and Traag's "STC Medium"
local extra_controls  "l.stcmedium"

logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'luputraag
  
* control for Dorussen and Ward's "Max Flow"
local extra_controls  "l.maxflow"

logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'dorussenward
  
* control for Mousseau's "Lower CIE"
local extra_controls  "l.sml_CIE"

logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'mousseau  
  
* control for Peterson and Thies's "Intra-Industry Trade"
local extra_controls  "l.intra_index_final"

logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'petersonthies
  
    
* TABLE 7
esttab a_appx7* , b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*py* *dec*)  order(L.exports *lowerdep*)                           
  
  
**********************
* Appendix - Table 8 *
**********************

preserve
keep if hidep2015 <10 & hidep2015 !=.

* main variables
local propsim_main    "l.exports l.lowerdep2015"  
local model       "appx8"

* controls
local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.s3un majmaj majmin l.rivalry both_europe dec_1 dec_2 dec_3"
local extra_controls  ""

* 1st dependent variable - All MIDs
local dv    "mid_init mid_py*"
local dv_abbr "a_"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

* 2nd dependent variable - Fatal MIDs
local dv    "fatal_init fatal_py*"
local dv_abbr "f_"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

* 3rd dependent variable - High-Hostility MIDs
local dv    "hihost_init hihost_py*"
local dv_abbr "h_"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

restore

  
* TABLE 8
esttab a_appx8* f_appx8* h_appx8*, b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*py* *dec*) order(L.exports *lowerdep*)                           



**********************
* Appendix - Table 9 *
**********************

* main variables
local propsim_main    "l.exports l.lowerdep2015"  
local model       "appx9"

* controls
local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.s3un majmaj majmin l.rivalry both_europe"
local extra_controls  "i.year"

* 1st dependent variable - All MIDs
local dv    "mid_init mid_py*"
local dv_abbr "a_"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

* 2nd dependent variable - Fatal MIDs
local dv    "fatal_init fatal_py*"
local dv_abbr "f_"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

* 3rd dependent variable - High-Hostility MIDs
local dv    "hihost_init hihost_py*"
local dv_abbr "h_"

*
logit `dv' `controls' `propsim_main'  `extra_controls'  if ongoing ==0  , cl(dyad_num) robust
  est store `dv_abbr'`model'

  
* TABLE 9
esttab a_appx9* f_appx9* h_appx9*, b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*py* *year*)  order(L.exports *lowerdep*)                           


*******************************
* Appendix - Tables 10 and 11 *
*******************************

* Calculated above in the same section with "Main Text - Table 2"

* Appendix - Table 10
esttab f_oil f_strat f_rawmanuf, b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*py* *dec*) 

* Appendix - Table 11
esttab h_oil h_strat h_rawmanuf, b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*py* *dec*) 


***********************
* Appendix - Table 12 *
***********************

* Multiple imputation files elsewhere
    
    
***********************
* Appendix - Table 13 *
***********************

* generate indicators of conflict the in the last 5 years
gen mid5yr =0
replace mid5yr =1 if l.mid_init ==1 | l2.mid_init ==1 | l3.mid_init ==1 | ///
    l4.mid_init ==1 | l5.mid_init ==1
    
gen fatal5yr =0
replace fatal5yr =1 if l.fatal_init ==1 | l2.fatal_init ==1 | l3.fatal_init ==1 | ///
    l4.fatal_init ==1 | l5.fatal_init ==1

gen hihost5yr =0
replace hihost5yr =1 if l.hihost_init ==1 | l2.hihost_init ==1 | l3.hihost_init ==1 | ///
    l4.hihost_init ==1 | l5.hihost_init ==1

    
local controls      "contig_dummy lndist l.pwin_cap l.jointdem l.s3un majmaj majmin both_europe dec_1 dec_2 dec_3"
local extra_controls  "l.low_gdppc l.joint_gatt l.lower_open"
    
*
reg exports l.exports l.mid5yr `controls' `extra_controls', cl(dyad_num) 
  est store endog_exposim1
reg exports l.exports l.fatal5yr `controls' `extra_controls', cl(dyad_num)
  est store endog_exposim2 
reg exports l.exports l.hihost5yr `controls' `extra_controls', cl(dyad_num) 
  est store endog_exposim3
reg exports l.exports l.rivalry `controls' `extra_controls', cl(dyad_num) 
  est store endog_exposim4
  
esttab endog*, b(3) se(3) stats(N ll aic) star(* 0.1 ** 0.05 *** 0.01) drop(*dec*)  order(*5yr L.rivalry)
